using UnityEngine;
using UnityEngine.UI;
using QFramework;

namespace QFramework.Adventure
{
	public class SetPanelData : UIPanelData
	{
	}
	public partial class SetPanel : UIPanel
	{
		protected override void OnInit(IUIData uiData = null)
		{
			mData = uiData as SetPanelData ?? new SetPanelData();
			// please add init code here

			btn_close.onClick.AddListener(() => { AudioKit.PlaySound(GameConfig.Auido_Btn01); CloseSelf(); });
		}
		
		protected override void OnOpen(IUIData uiData = null)
		{
            var vMusicVolume = PlayerPrefs.GetFloat("MusicVolume",1);
            slider_Musicvalue.value = vMusicVolume;
            AudioKit.Settings.MusicVolume.Value = vMusicVolume;


            var vSoundvalue =	PlayerPrefs.GetFloat("Soundvalue",1);
			slider_Soundvalue.value = vSoundvalue;
			AudioKit.Settings.SoundVolume.Value = vSoundvalue;


        
         

        }
		private void Update()
        {
         

            if (slider_Musicvalue.value != PlayerPrefs.GetFloat("MusicVolume", 1))
            {
                PlayerPrefs.SetFloat("MusicVolume", slider_Musicvalue.value);
                AudioKit.Settings.MusicVolume.Value = PlayerPrefs.GetFloat("MusicVolume", 1);

            }
            if (slider_Soundvalue.value != PlayerPrefs.GetFloat("Soundvalue", 1))
            {
                PlayerPrefs.SetFloat("Soundvalue", slider_Soundvalue.value);
                AudioKit.Settings.SoundVolume.Value = PlayerPrefs.GetFloat("Soundvalue", 1);

            }


        }

		protected override void OnShow()
		{
		}
		
		protected override void OnHide()
		{
		}
		
		protected override void OnClose()
		{
		}
	}
}
